# Set the working directory to the project folder.
project_folder <- "."
setwd(project_folder)
library(Seurat)
library(ggplot2)
library(ggalluvial)
library(grid)
library(forcats)
library(see)
library(dplyr)
library(gghalves)
library(viridis)
library(stringr)
library(RColorBrewer)
library(kableExtra)
library(ggpubr)
library(rstatix)
library(clusterProfiler)
library(EnhancedVolcano)
library(introdataviz)
cols1 <- c(`0 CD8+ Eff mem (EM)` = "#A6CEE3", `1 CD8+ Eff cytotox (Ecyt)` = "#1F78B4",
    `3 CD4+ Naive/SCM` = "#33A02C", `6 CD4+ Central/Effector memory (CM/EM)` = "#FDBF6F",
    `9 γδ Tcells` = "#6A3D9A", `Proliferative cells` = "#F7D764")
cols2 <- c(`0 CD8+ Eff mem (EM)` = "#A6CEE3", `1 CD8+ Eff cytotox (Ecyt)` = "#1F78B4",
    `2 Early prolif: HMGN+/HMGB+/PCNA+ cells` = "#B2DF8A", `3 CD4+ Naive/SCM` = "#33A02C",
    `4 Early  prolif: MCM3/5/7+ PCNA+ cells` = "#FB9A99", `5 Late prolif: histones enriched MKI67+ cells` = "#E31A1C",
    `6 CD4+ Central/Effector memory (CM/EM)` = "#FDBF6F", `7 Ribosomal/Mitocondrial/Degradated cells` = "#FF7F00",
    `8 Late prolif: CDK+/CDC+/AURKA+ MIK67+ cells` = "#CAB2D6", `9 γδ Tcells` = "#6A3D9A")
cols3 <- c(`CAR+` = "#66c2a5", `CAR-` = "#fc8d62")
cols4 <- c("#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51")
cols5 <- c(IP = "#4E6AAB", Peak = "#e78ac3")
cols6 <- c(CD4 = "#147D2C", CD8 = "#F5C936", Unknown = "#7f7f7f", `CD4- CD8-` = "#38369A")
cols7 <- c("#F8766D", "#00BA38", "#619CFF")
cols8 <- c("#E69F00FF", "#56B4E9FF", "#009E73FF", "#F0E442FF")

Tonic Signaling

Joining the genes of activation and exhaustion

integrated.obj <- readRDS("integrated.obj.rds")

Analysis.

Define genes to analyse.

tonic_genes <- c("CD28", "CD40LG", "TNFRSF4", "TNFRSF9", "CD74", "HLA-DBR1", "NKB1",
    "ICOS", "CD27", "CD25", "CD69", "TOX", "PDCD1", "LAG3", "TIGIT", "CASP8", "HAVCR2",
    "CTLA4", "PTPN11", "CD160", "CD244")

integrated.obj <- AddModuleScore(object = integrated.obj, features = list(tonic_genes),
    name = "Tonic.MGM")
## Warning: The following features are not present in the object: HLA-DBR1, NKB1,
## CD25, not searching for symbol synonyms
FeaturePlot(integrated.obj, features = tonic_genes)
## Warning in FetchData.Seurat(object = object, vars = c(dims, "ident", features),
## : The following requested variables were not found: HLA-DBR1, NKB1, CD25

IP

integrated.obj.Peak <- subset(x = integrated.obj, subset = Timepoint == "IP")

aux_df1 <- data.frame(seurat_clusters = Idents(integrated.obj.Peak), integrated.obj.Peak[[]],
    FetchData(integrated.obj.Peak, vars = tonic_genes, slot = "data"))
## Warning in FetchData.Seurat(integrated.obj.Peak, vars = tonic_genes, slot =
## "data"): The following requested variables were not found: HLA-DBR1, NKB1, CD25

Print the average, max and sd for each gene

aux_df1 %>%
    group_by(Patient_id, Timepoint, Class1) %>%
    summarise_at(vars(one_of(tonic_genes)), list(mean = mean, max = max, sd = sd)) %>%
    kbl() %>%
    kable_styling(bootstrap_options = c("striped", "hover")) %>%
    scroll_box(width = "100%", height = "500px")
## Warning: Unknown columns: `HLA-DBR1`, `NKB1`, `CD25`
Patient_id Timepoint Class1 CD28_mean CD40LG_mean TNFRSF4_mean TNFRSF9_mean CD74_mean ICOS_mean CD27_mean CD69_mean TOX_mean PDCD1_mean LAG3_mean TIGIT_mean CASP8_mean HAVCR2_mean CTLA4_mean PTPN11_mean CD160_mean CD244_mean CD28_max CD40LG_max TNFRSF4_max TNFRSF9_max CD74_max ICOS_max CD27_max CD69_max TOX_max PDCD1_max LAG3_max TIGIT_max CASP8_max HAVCR2_max CTLA4_max PTPN11_max CD160_max CD244_max CD28_sd CD40LG_sd TNFRSF4_sd TNFRSF9_sd CD74_sd ICOS_sd CD27_sd CD69_sd TOX_sd PDCD1_sd LAG3_sd TIGIT_sd CASP8_sd HAVCR2_sd CTLA4_sd PTPN11_sd CD160_sd CD244_sd
patient1 IP CAR+ 0.2032246 0.4474325 0.0151699 0.0132654 3.649087 0.1740156 0.9782899 0.7893528 0.0376454 0.0115405 0.0813741 0.0303534 0.2902659 0.6035741 0.1048616 0.1166621 0.0010123 0.1086688 2.742635 3.831090 1.664776 2.773125 5.894663 2.153638 3.294562 3.061552 1.828519 1.674925 2.595199 2.789866 2.394267 3.232960 2.471658 2.165850 1.228483 2.098082 0.4687367 0.7957521 0.1288320 0.1406676 0.7928318 0.4120311 0.8633980 0.8147787 0.1946200 0.1104411 0.3111944 0.2052296 0.5268369 0.7503687 0.3478176 0.3450004 0.0337341 0.3343427
patient1 IP CAR- 0.1819366 0.2889402 0.0060565 0.0081733 3.772949 0.1671164 1.0449855 0.7851441 0.0438133 0.0015782 0.0721218 0.0349780 0.3126053 0.6478740 0.1225458 0.0987665 0.0000000 0.1382920 2.507998 3.605574 1.868636 2.704251 5.624653 2.343362 3.514258 3.982876 2.157349 1.828519 2.764656 2.360999 2.598360 3.235537 2.909604 2.617869 0.000000 2.289815 0.4684201 0.6742635 0.0944544 0.1043026 0.6945903 0.4268390 0.9198547 0.8596306 0.2272514 0.0473074 0.3074726 0.2166893 0.5779341 0.8105478 0.3933710 0.3428870 0.0000000 0.3973685
patient2 IP CAR+ 0.2794793 0.2681035 0.0269683 0.0245779 4.549719 0.1626954 0.1689869 0.8437777 0.0280723 0.0008401 0.0231511 0.0348559 0.2676086 0.1248477 0.2163604 0.0649876 0.0032417 0.0177397 3.503515 3.597722 2.314096 2.580975 6.459877 2.805783 3.004467 4.240553 2.316564 1.588647 2.274803 3.351594 3.310004 3.056023 3.708706 2.347629 1.547767 2.352779 0.6717792 0.6849205 0.2106883 0.2065098 0.8538531 0.5207312 0.5504364 1.1184955 0.2219640 0.0365327 0.1970317 0.2585800 0.6604225 0.4593957 0.6146259 0.3307010 0.0658559 0.1783994
patient2 IP CAR- 0.2202422 0.1845875 0.0087081 0.0264293 3.857272 0.1509738 0.1669816 1.3033588 0.1329800 0.0018525 0.1110096 0.1265319 0.3445649 0.1722950 0.2872130 0.0556388 0.0123455 0.0998044 2.938584 3.251708 2.396987 2.339117 5.719099 2.830207 3.017315 4.751086 2.896389 2.130419 2.927639 2.807975 3.165175 3.075521 3.925312 2.371941 2.088728 2.686479 0.6291649 0.5975152 0.1333319 0.2138125 0.9632451 0.5130267 0.5849974 1.2823109 0.4778580 0.0628226 0.4505932 0.4870521 0.7515901 0.5607135 0.7089793 0.3173442 0.1361415 0.4293448
patient3 IP CAR+ 0.2334054 0.4018521 0.0672190 0.0211645 3.023431 0.1776469 0.6213310 0.7513492 0.0202303 0.0065893 0.0396427 0.1739868 0.2366977 0.3123091 0.1381399 0.1060683 0.0010923 0.0216456 3.232025 3.539359 2.632121 2.586069 5.681022 2.471989 3.173179 3.707736 2.336580 2.386160 2.598072 3.355145 2.703210 2.936892 2.928755 2.511112 1.300642 2.295417 0.5828129 0.7832169 0.3106180 0.1792936 1.0160658 0.4970965 0.8867879 0.9549400 0.1739901 0.0983094 0.2414091 0.5291046 0.5724579 0.6585805 0.4618320 0.3817883 0.0343522 0.1777855
patient3 IP CAR- 0.1673013 0.2368321 0.0222979 0.0359687 2.848937 0.1880342 0.6218271 0.8341690 0.0322228 0.0119056 0.0790158 0.2506993 0.2733419 0.3715731 0.1921911 0.0852337 0.0009027 0.0367287 3.413882 3.476551 2.277941 2.944534 5.264283 2.594053 3.297379 3.719444 2.241067 2.734293 2.156335 3.241421 2.771652 3.400714 2.877991 2.285045 1.206053 2.444152 0.5278786 0.6522536 0.1966603 0.2561078 1.1008412 0.5276756 0.9371440 1.0313439 0.2251764 0.1497221 0.3450768 0.6388775 0.6342853 0.7568480 0.5543421 0.3578132 0.0329962 0.2360286
patient4 IP CAR+ 0.1036454 0.4108187 0.0242136 0.0192158 3.465074 0.1289096 0.8560974 1.1911339 0.1004193 0.0025586 0.0791824 0.0616815 0.1892464 0.3208528 0.0680787 0.0570633 0.0033415 0.0796114 2.782725 3.332797 2.034856 2.405659 5.683235 2.878519 3.354256 3.443542 2.341661 1.996790 2.970193 2.635120 2.832461 2.676339 2.489042 2.195094 1.685585 2.275195 0.3873189 0.7427409 0.1811134 0.1622388 0.8899900 0.4127893 0.9212579 0.9617711 0.3536400 0.0636137 0.3475024 0.3076230 0.4946712 0.6093553 0.3112272 0.2729475 0.0658836 0.3156493
patient4 IP CAR- 0.0790173 0.1842659 0.0067281 0.0475107 3.905367 0.1155074 0.7206828 1.2312237 0.1198115 0.0090032 0.1612589 0.1446020 0.2551264 0.3269258 0.0872782 0.0521816 0.0081601 0.1855464 3.293625 3.209271 2.334051 3.383802 5.901725 2.999922 3.661372 3.844274 2.966982 2.076429 3.033792 2.992338 2.672567 2.717622 2.894774 2.329854 2.514412 2.470997 0.3675451 0.5601953 0.1082358 0.2863148 1.0704705 0.4215263 1.0037946 1.0808588 0.4311535 0.1245953 0.5138581 0.4778170 0.6114925 0.6821221 0.3724257 0.2848675 0.1228411 0.5134177
patient5 IP CAR+ 0.3419305 0.4275277 0.0019027 0.0170120 3.809501 0.3595868 0.5947328 0.6664258 0.0367158 0.0023118 0.0478246 0.0882451 0.4836477 0.2986820 0.2303836 0.0992842 0.0000000 0.0407770 3.216728 4.195087 1.660966 2.419071 5.932217 3.522941 3.491865 4.406818 2.256993 2.114885 2.897198 3.287401 3.393537 3.350709 3.682854 2.703860 0.000000 2.305922 0.7164245 0.8525841 0.0471570 0.1624464 0.9630692 0.7347437 0.9409721 0.9915923 0.2350100 0.0636018 0.2834331 0.4003794 0.8212958 0.6799696 0.6263841 0.4030223 0.0000000 0.2535224
patient5 IP CAR- 0.2792884 0.4001225 0.0000000 0.0288433 3.662810 0.2951297 0.8958281 0.6999004 0.0542005 0.0020368 0.0672935 0.1551116 0.3983290 0.3685628 0.2229700 0.0823926 0.0027375 0.0552528 3.226201 3.230468 0.000000 2.316564 5.610964 2.924298 3.566537 4.033406 3.043571 1.573017 2.710387 3.017007 3.038195 3.419821 3.087422 2.365795 1.804370 2.338693 0.6442354 0.8075789 0.0000000 0.2035010 0.9114614 0.6435492 1.0453935 0.9706036 0.2865558 0.0555266 0.3190037 0.5069474 0.7361292 0.7355256 0.5811437 0.3583258 0.0585232 0.2803163
FeaturePlot(integrated.obj, features = "Tonic.MGM1")

# CAR+/CAR-

ggplot(aux_df1, aes(x = fct_reorder(Class1, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = Class1)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols3)

# CD4/CD8
aux_df1 <- aux_df1[which(aux_df1$final_criteria != "Unknown"), ]

ggplot(aux_df1, aes(x = fct_reorder(final_criteria, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = final_criteria)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols6)

ggplot(aux_df1, aes(x = fct_reorder(Class1, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = final_criteria)) + geom_split_violin() + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols6)

ggplot(aux_df1, aes(x = fct_reorder(final_criteria, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = Class1)) + geom_split_violin() + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols3)

Peak

integrated.obj.Peak <- subset(x = integrated.obj, subset = Timepoint == "Peak")

aux_df1 <- data.frame(seurat_clusters = Idents(integrated.obj.Peak), integrated.obj.Peak[[]],
    FetchData(integrated.obj.Peak, vars = tonic_genes, slot = "data"))
## Warning in FetchData.Seurat(integrated.obj.Peak, vars = tonic_genes, slot =
## "data"): The following requested variables were not found: HLA-DBR1, NKB1, CD25

Print the average, max and sd for each gene

aux_df1 %>%
    group_by(Patient_id, Timepoint, Class1) %>%
    summarise_at(vars(one_of(tonic_genes)), list(mean = mean, max = max, sd = sd)) %>%
    kbl() %>%
    kable_styling(bootstrap_options = c("striped", "hover")) %>%
    scroll_box(width = "100%", height = "500px")
## Warning: Unknown columns: `HLA-DBR1`, `NKB1`, `CD25`
Patient_id Timepoint Class1 CD28_mean CD40LG_mean TNFRSF4_mean TNFRSF9_mean CD74_mean ICOS_mean CD27_mean CD69_mean TOX_mean PDCD1_mean LAG3_mean TIGIT_mean CASP8_mean HAVCR2_mean CTLA4_mean PTPN11_mean CD160_mean CD244_mean CD28_max CD40LG_max TNFRSF4_max TNFRSF9_max CD74_max ICOS_max CD27_max CD69_max TOX_max PDCD1_max LAG3_max TIGIT_max CASP8_max HAVCR2_max CTLA4_max PTPN11_max CD160_max CD244_max CD28_sd CD40LG_sd TNFRSF4_sd TNFRSF9_sd CD74_sd ICOS_sd CD27_sd CD69_sd TOX_sd PDCD1_sd LAG3_sd TIGIT_sd CASP8_sd HAVCR2_sd CTLA4_sd PTPN11_sd CD160_sd CD244_sd
patient1 Peak CAR+ 0.3627902 0.0239788 0.0008582 0.2607525 4.203406 0.0622529 1.9005337 0.9428480 0.2604470 0.0091001 0.0818566 0.7503858 0.6262466 0.3557748 0.3594150 0.0733418 0.0162043 0.0319460 2.950523 3.404457 1.957659 3.302408 6.358915 2.488029 4.330509 4.041383 3.168368 2.314917 2.681394 3.597106 3.535308 3.378564 3.271819 2.363612 2.670479 2.629132 0.7211257 0.2178625 0.0409897 0.6334359 0.7651602 0.3150630 1.1067263 1.044877 0.6263218 0.1283981 0.3600585 0.9693242 0.9120657 0.7284393 0.7312171 0.3355524 0.1744354 0.2295675
patient1 Peak CAR- 0.1913131 0.0703242 0.0000000 0.0673668 3.594059 0.0593826 0.7344711 1.0785020 0.1808232 0.0231551 0.0950457 0.1896758 0.5046009 0.1757019 0.1393121 0.0425266 0.0634287 0.0759262 2.891553 2.784861 0.000000 2.947666 6.724743 2.620819 3.796418 3.785936 2.649050 2.237321 2.586637 3.247342 3.102183 2.954825 2.865933 2.285045 2.446076 2.954825 0.5414251 0.3468586 0.0000000 0.3387592 1.0793991 0.3139337 1.1058965 1.089465 0.5483919 0.1952936 0.3903964 0.5771825 0.8457735 0.5366251 0.4806785 0.2604137 0.3395152 0.3670311
patient2 Peak CAR+ 0.1649673 0.0373742 0.0000000 0.0440195 3.488778 0.0879091 0.5882039 1.2325634 0.2260729 0.0621802 0.0840889 0.2745809 0.4844360 0.1431385 0.1834368 0.0471882 0.1800999 0.1040726 3.088088 3.157958 0.000000 2.832461 5.603116 2.394267 3.516896 3.935099 2.874830 3.105571 2.602111 3.389573 3.416728 3.196868 3.382677 2.495654 3.262917 2.895581 0.5611679 0.2840945 0.0000000 0.3075817 0.9824115 0.3999162 1.0255506 1.249697 0.6407133 0.3522332 0.3787173 0.7220320 0.8939452 0.5258474 0.5930657 0.2918584 0.6095903 0.4491265
patient2 Peak CAR- 0.0729409 0.0325194 0.0200617 0.0205974 3.454619 0.0685784 0.2450133 1.3602044 0.2700518 0.0537900 0.1010064 0.3139522 0.5009086 0.1742366 0.1015965 0.0915390 0.3199152 0.1877751 2.484494 2.683933 2.600378 2.411182 5.454322 2.720268 4.281721 4.078757 3.103537 2.611999 2.918480 3.760907 3.457753 2.982857 3.250913 2.819763 3.364596 2.712354 0.3391582 0.2414754 0.1957288 0.1931668 1.0083317 0.3310355 0.6681393 1.211465 0.6809500 0.3026732 0.4110867 0.7286523 0.8587549 0.5513697 0.4206299 0.3843462 0.7503000 0.5747315
patient3 Peak CAR+ 0.3627520 0.0322195 0.0000000 0.0646778 2.812122 0.1120834 0.9173257 1.5548438 0.1095640 0.0088800 0.0595547 0.1946933 0.5101828 0.1063349 0.1773147 0.0528233 0.0214495 0.0443742 3.298215 2.729210 0.000000 2.936892 5.073486 3.057955 3.666001 4.464503 2.870109 2.207243 2.395173 3.354256 3.340145 2.817541 3.585271 2.956552 3.327971 2.394267 0.8264029 0.2587836 0.0000000 0.3678444 1.3332435 0.4707304 1.1765913 1.365613 0.4593096 0.1285894 0.3406672 0.6134894 0.9496656 0.4682585 0.6006709 0.3219202 0.2171398 0.2895659
patient3 Peak CAR- 0.2016444 0.0803131 0.0077465 0.0154524 2.563344 0.1173346 0.7340135 1.3066376 0.1163087 0.0213365 0.0650204 0.2161661 0.3166103 0.0312517 0.0817068 0.0418716 0.0382169 0.0615587 2.890750 2.833213 2.205085 2.956552 5.280605 3.441517 3.687588 4.158982 2.765585 2.396987 2.647221 3.122703 3.218876 2.709077 3.618930 2.529509 2.930153 2.624372 0.5922904 0.3821949 0.1198768 0.1811185 1.3257329 0.4633052 1.0448009 1.204572 0.4529255 0.1989044 0.3355986 0.6145813 0.7292474 0.2411141 0.4059750 0.2711486 0.2646053 0.3333049
patient4 Peak CAR+ 0.1943009 0.0493635 0.0000000 0.1480889 3.993479 0.0917020 1.2380745 1.0357098 0.2151029 0.0146933 0.0900462 0.4641705 0.3714575 0.1465176 0.1360186 0.0466967 0.0122115 0.0375885 2.840016 2.995400 0.000000 2.797789 5.596637 3.341898 3.759834 3.731695 2.483990 2.416278 2.629729 3.625132 3.196868 2.999922 2.885145 2.336580 2.424215 2.682028 0.5474784 0.3157714 0.0000000 0.4768167 0.8868135 0.4063849 1.1300259 1.084852 0.5588310 0.1675899 0.3831170 0.8014912 0.7326634 0.4747680 0.4678587 0.2744097 0.1418653 0.2573660
patient4 Peak CAR- 0.1224278 0.0802020 0.0013005 0.0108890 3.574894 0.1193289 0.2880645 0.9882553 0.1020416 0.0511156 0.0806722 0.1677924 0.5973533 0.1129296 0.0899108 0.0411042 0.0737981 0.0493066 3.029411 3.262917 2.326511 2.850702 5.418546 3.029411 3.593488 3.789069 3.037880 2.486007 2.505411 3.380390 3.612768 3.077494 2.826463 2.368424 3.395127 2.395173 0.4674077 0.3973381 0.0550047 0.1419216 1.1215928 0.4682750 0.7435651 1.162460 0.4457610 0.3060077 0.3810845 0.5626963 0.9806816 0.4697125 0.4138734 0.2747432 0.3911591 0.3107322
patient5 Peak CAR+ 0.1489820 0.0296727 0.0000000 0.0648870 3.279515 0.0968585 1.5172309 1.0504938 0.2362125 0.0085494 0.1007335 0.4346520 0.5235027 0.3177974 0.1234066 0.0696449 0.0199241 0.0581654 2.823479 2.849934 0.000000 2.896389 5.075855 2.253173 3.899294 3.997759 2.884879 2.010668 2.593480 3.683394 3.685605 2.820505 3.505550 2.384369 3.025672 2.760254 0.4853103 0.2435035 0.0000000 0.3132820 0.9454487 0.3746767 1.0952072 1.072427 0.5948786 0.1172244 0.3926656 0.8010536 0.8326317 0.6705709 0.4385842 0.3252105 0.1966183 0.3090714
patient5 Peak CAR- 0.1148940 0.0582123 0.0000000 0.0472712 2.927868 0.0795384 1.1184764 1.2214102 0.2211236 0.0576606 0.1539991 0.3203429 0.5896540 0.2865367 0.1068664 0.0459676 0.0597031 0.0844227 3.046429 2.672986 0.000000 2.844580 5.379268 2.709296 4.177422 3.976987 2.709077 2.439362 3.366331 3.533347 3.279168 3.103029 3.046429 2.280302 3.146529 2.520524 0.4348365 0.3198854 0.0000000 0.2940132 1.1507081 0.3543391 1.1572611 1.142109 0.5890353 0.3065511 0.4901073 0.7276506 0.8761924 0.6571549 0.4295617 0.2726177 0.3466872 0.3819113
FeaturePlot(integrated.obj, features = "Tonic.MGM1")

# CAR+/CAR-

ggplot(aux_df1, aes(x = fct_reorder(Class1, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = Class1)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols3)

# CD4/CD8
aux_df1 <- aux_df1[which(aux_df1$final_criteria != "Unknown"), ]

ggplot(aux_df1, aes(x = fct_reorder(final_criteria, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = final_criteria)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols6)

CAR+

integrated.obj.Peak <- subset(x = integrated.obj, subset = Class1 == "CAR+")

aux_df1 <- data.frame(seurat_clusters = Idents(integrated.obj.Peak), integrated.obj.Peak[[]],
    FetchData(integrated.obj.Peak, vars = tonic_genes, slot = "data"))
## Warning in FetchData.Seurat(integrated.obj.Peak, vars = tonic_genes, slot =
## "data"): The following requested variables were not found: HLA-DBR1, NKB1, CD25

Print the average, max and sd for each gene

aux_df1 %>%
    group_by(Patient_id, Timepoint, Class1) %>%
    summarise_at(vars(one_of(tonic_genes)), list(mean = mean, max = max, sd = sd)) %>%
    kbl() %>%
    kable_styling(bootstrap_options = c("striped", "hover")) %>%
    scroll_box(width = "100%", height = "500px")
## Warning: Unknown columns: `HLA-DBR1`, `NKB1`, `CD25`
Patient_id Timepoint Class1 CD28_mean CD40LG_mean TNFRSF4_mean TNFRSF9_mean CD74_mean ICOS_mean CD27_mean CD69_mean TOX_mean PDCD1_mean LAG3_mean TIGIT_mean CASP8_mean HAVCR2_mean CTLA4_mean PTPN11_mean CD160_mean CD244_mean CD28_max CD40LG_max TNFRSF4_max TNFRSF9_max CD74_max ICOS_max CD27_max CD69_max TOX_max PDCD1_max LAG3_max TIGIT_max CASP8_max HAVCR2_max CTLA4_max PTPN11_max CD160_max CD244_max CD28_sd CD40LG_sd TNFRSF4_sd TNFRSF9_sd CD74_sd ICOS_sd CD27_sd CD69_sd TOX_sd PDCD1_sd LAG3_sd TIGIT_sd CASP8_sd HAVCR2_sd CTLA4_sd PTPN11_sd CD160_sd CD244_sd
patient1 IP CAR+ 0.2032246 0.4474325 0.0151699 0.0132654 3.649087 0.1740156 0.9782899 0.7893528 0.0376454 0.0115405 0.0813741 0.0303534 0.2902659 0.6035741 0.1048616 0.1166621 0.0010123 0.1086688 2.742635 3.831090 1.664776 2.773125 5.894663 2.153638 3.294562 3.061552 1.828519 1.674925 2.595199 2.789866 2.394267 3.232960 2.471658 2.165850 1.228483 2.098082 0.4687367 0.7957521 0.1288320 0.1406676 0.7928318 0.4120311 0.8633980 0.8147787 0.1946200 0.1104411 0.3111944 0.2052296 0.5268369 0.7503687 0.3478176 0.3450004 0.0337341 0.3343427
patient1 Peak CAR+ 0.3627902 0.0239788 0.0008582 0.2607525 4.203406 0.0622529 1.9005337 0.9428480 0.2604470 0.0091001 0.0818566 0.7503858 0.6262466 0.3557748 0.3594150 0.0733418 0.0162043 0.0319460 2.950523 3.404457 1.957659 3.302408 6.358915 2.488029 4.330509 4.041383 3.168368 2.314917 2.681394 3.597106 3.535308 3.378564 3.271819 2.363612 2.670479 2.629132 0.7211257 0.2178625 0.0409897 0.6334359 0.7651602 0.3150630 1.1067263 1.0448767 0.6263218 0.1283981 0.3600585 0.9693242 0.9120657 0.7284393 0.7312171 0.3355524 0.1744354 0.2295675
patient2 IP CAR+ 0.2794793 0.2681035 0.0269683 0.0245779 4.549719 0.1626954 0.1689869 0.8437777 0.0280723 0.0008401 0.0231511 0.0348559 0.2676086 0.1248477 0.2163604 0.0649876 0.0032417 0.0177397 3.503515 3.597722 2.314096 2.580975 6.459877 2.805783 3.004467 4.240553 2.316564 1.588647 2.274803 3.351594 3.310004 3.056023 3.708706 2.347629 1.547767 2.352779 0.6717792 0.6849205 0.2106883 0.2065098 0.8538531 0.5207312 0.5504364 1.1184955 0.2219640 0.0365327 0.1970317 0.2585800 0.6604225 0.4593957 0.6146259 0.3307010 0.0658559 0.1783994
patient2 Peak CAR+ 0.1649673 0.0373742 0.0000000 0.0440195 3.488778 0.0879091 0.5882039 1.2325634 0.2260729 0.0621802 0.0840889 0.2745809 0.4844360 0.1431385 0.1834368 0.0471882 0.1800999 0.1040726 3.088088 3.157958 0.000000 2.832461 5.603116 2.394267 3.516896 3.935099 2.874830 3.105571 2.602111 3.389573 3.416728 3.196868 3.382677 2.495654 3.262917 2.895581 0.5611679 0.2840945 0.0000000 0.3075817 0.9824115 0.3999162 1.0255506 1.2496967 0.6407133 0.3522332 0.3787173 0.7220320 0.8939452 0.5258474 0.5930657 0.2918584 0.6095903 0.4491265
patient3 IP CAR+ 0.2334054 0.4018521 0.0672190 0.0211645 3.023431 0.1776469 0.6213310 0.7513492 0.0202303 0.0065893 0.0396427 0.1739868 0.2366977 0.3123091 0.1381399 0.1060683 0.0010923 0.0216456 3.232025 3.539359 2.632121 2.586069 5.681022 2.471989 3.173179 3.707736 2.336580 2.386160 2.598072 3.355145 2.703210 2.936892 2.928755 2.511112 1.300642 2.295417 0.5828129 0.7832169 0.3106180 0.1792936 1.0160658 0.4970965 0.8867879 0.9549400 0.1739901 0.0983094 0.2414091 0.5291046 0.5724579 0.6585805 0.4618320 0.3817883 0.0343522 0.1777855
patient3 Peak CAR+ 0.3627520 0.0322195 0.0000000 0.0646778 2.812122 0.1120834 0.9173257 1.5548438 0.1095640 0.0088800 0.0595547 0.1946933 0.5101828 0.1063349 0.1773147 0.0528233 0.0214495 0.0443742 3.298215 2.729210 0.000000 2.936892 5.073486 3.057955 3.666001 4.464503 2.870109 2.207243 2.395173 3.354256 3.340145 2.817541 3.585271 2.956552 3.327971 2.394267 0.8264029 0.2587836 0.0000000 0.3678444 1.3332435 0.4707304 1.1765913 1.3656132 0.4593096 0.1285894 0.3406672 0.6134894 0.9496656 0.4682585 0.6006709 0.3219202 0.2171398 0.2895659
patient4 IP CAR+ 0.1036454 0.4108187 0.0242136 0.0192158 3.465074 0.1289096 0.8560974 1.1911339 0.1004193 0.0025586 0.0791824 0.0616815 0.1892464 0.3208528 0.0680787 0.0570633 0.0033415 0.0796114 2.782725 3.332797 2.034856 2.405659 5.683235 2.878519 3.354256 3.443542 2.341661 1.996790 2.970193 2.635120 2.832461 2.676339 2.489042 2.195094 1.685585 2.275195 0.3873189 0.7427409 0.1811134 0.1622388 0.8899900 0.4127893 0.9212579 0.9617711 0.3536400 0.0636137 0.3475024 0.3076230 0.4946712 0.6093553 0.3112272 0.2729475 0.0658836 0.3156493
patient4 Peak CAR+ 0.1943009 0.0493635 0.0000000 0.1480889 3.993479 0.0917020 1.2380745 1.0357098 0.2151029 0.0146933 0.0900462 0.4641705 0.3714575 0.1465176 0.1360186 0.0466967 0.0122115 0.0375885 2.840016 2.995400 0.000000 2.797789 5.596637 3.341898 3.759834 3.731695 2.483990 2.416278 2.629729 3.625132 3.196868 2.999922 2.885145 2.336580 2.424215 2.682028 0.5474784 0.3157714 0.0000000 0.4768167 0.8868135 0.4063849 1.1300259 1.0848520 0.5588310 0.1675899 0.3831170 0.8014912 0.7326634 0.4747680 0.4678587 0.2744097 0.1418653 0.2573660
patient5 IP CAR+ 0.3419305 0.4275277 0.0019027 0.0170120 3.809501 0.3595868 0.5947328 0.6664258 0.0367158 0.0023118 0.0478246 0.0882451 0.4836477 0.2986820 0.2303836 0.0992842 0.0000000 0.0407770 3.216728 4.195087 1.660966 2.419071 5.932217 3.522941 3.491865 4.406818 2.256993 2.114885 2.897198 3.287401 3.393537 3.350709 3.682854 2.703860 0.000000 2.305922 0.7164245 0.8525841 0.0471570 0.1624464 0.9630692 0.7347437 0.9409721 0.9915923 0.2350100 0.0636018 0.2834331 0.4003794 0.8212958 0.6799696 0.6263841 0.4030223 0.0000000 0.2535224
patient5 Peak CAR+ 0.1489820 0.0296727 0.0000000 0.0648870 3.279515 0.0968585 1.5172309 1.0504938 0.2362125 0.0085494 0.1007335 0.4346520 0.5235027 0.3177974 0.1234066 0.0696449 0.0199241 0.0581654 2.823479 2.849934 0.000000 2.896389 5.075855 2.253173 3.899294 3.997759 2.884879 2.010668 2.593480 3.683394 3.685605 2.820505 3.505550 2.384369 3.025672 2.760254 0.4853103 0.2435035 0.0000000 0.3132820 0.9454487 0.3746767 1.0952072 1.0724268 0.5948786 0.1172244 0.3926656 0.8010536 0.8326317 0.6705709 0.4385842 0.3252105 0.1966183 0.3090714
FeaturePlot(integrated.obj, features = "Tonic.MGM1")

# IP/Peak

ggplot(aux_df1, aes(x = fct_reorder(Timepoint, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = Timepoint)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols5)

# CD4/CD8
aux_df1 <- aux_df1[which(aux_df1$final_criteria != "Unknown"), ]

ggplot(aux_df1, aes(x = fct_reorder(final_criteria, Tonic.MGM1, .fun = median, .desc = TRUE),
    y = Tonic.MGM1, fill = final_criteria)) + geom_violin(scale = "width") + geom_boxplot(outlier.shape = NA,
    width = 0.1) + theme_classic() + theme(axis.text.x = element_text(size = 16),
    axis.text.y = element_text(size = 16)) + theme(axis.text.x = element_text(angle = 90,
    vjust = 0.5, hjust = 1)) + xlab("") + scale_fill_manual(values = cols6)

Session Info

sessionInfo()
## R version 4.3.0 (2023-04-21)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.4.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## time zone: Europe/Madrid
## tzcode source: internal
## 
## attached base packages:
## [1] grid      stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] introdataviz_0.0.0.9003 EnhancedVolcano_1.18.0  ggrepel_0.9.3          
##  [4] clusterProfiler_4.8.1   rstatix_0.7.2           ggpubr_0.6.0           
##  [7] kableExtra_1.3.4        RColorBrewer_1.1-3      stringr_1.5.0          
## [10] viridis_0.6.3           viridisLite_0.4.2       gghalves_0.1.4         
## [13] dplyr_1.1.2             see_0.7.5               forcats_1.0.0          
## [16] ggalluvial_0.12.5       ggplot2_3.4.2           SeuratObject_4.1.3     
## [19] Seurat_4.3.0            knitr_1.43             
## 
## loaded via a namespace (and not attached):
##   [1] RcppAnnoy_0.0.20        splines_4.3.0           later_1.3.1            
##   [4] ggplotify_0.1.0         bitops_1.0-7            tibble_3.2.1           
##   [7] polyclip_1.10-4         lifecycle_1.0.3         globals_0.16.2         
##  [10] lattice_0.21-8          MASS_7.3-60             backports_1.4.1        
##  [13] magrittr_2.0.3          plotly_4.10.1           sass_0.4.6             
##  [16] rmarkdown_2.21          jquerylib_0.1.4         yaml_2.3.7             
##  [19] httpuv_1.6.11           sctransform_0.3.5       sp_1.6-0               
##  [22] spatstat.sparse_3.0-1   reticulate_1.28         cowplot_1.1.1          
##  [25] pbapply_1.7-0           DBI_1.1.3               abind_1.4-5            
##  [28] zlibbioc_1.46.0         rvest_1.0.3             Rtsne_0.16             
##  [31] purrr_1.0.1             ggraph_2.1.0            BiocGenerics_0.46.0    
##  [34] RCurl_1.98-1.12         yulab.utils_0.0.6       tweenr_2.0.2           
##  [37] GenomeInfoDbData_1.2.10 enrichplot_1.20.0       IRanges_2.34.0         
##  [40] S4Vectors_0.38.1        irlba_2.3.5.1           listenv_0.9.0          
##  [43] spatstat.utils_3.0-3    tidytree_0.4.2          goftest_1.2-3          
##  [46] spatstat.random_3.1-5   fitdistrplus_1.1-11     parallelly_1.35.0      
##  [49] svglite_2.1.1           leiden_0.4.3            codetools_0.2-19       
##  [52] ggforce_0.4.1           DOSE_3.26.1             xml2_1.3.4             
##  [55] tidyselect_1.2.0        aplot_0.1.10            farver_2.1.1           
##  [58] matrixStats_0.63.0      stats4_4.3.0            spatstat.explore_3.2-1 
##  [61] webshot_0.5.4           jsonlite_1.8.4          tidygraph_1.2.3        
##  [64] ellipsis_0.3.2          progressr_0.13.0        ggridges_0.5.4         
##  [67] survival_3.5-5          systemfonts_1.0.4       tools_4.3.0            
##  [70] treeio_1.24.0           ica_1.0-3               Rcpp_1.0.10            
##  [73] glue_1.6.2              gridExtra_2.3           xfun_0.39              
##  [76] qvalue_2.32.0           GenomeInfoDb_1.36.0     withr_2.5.0            
##  [79] formatR_1.14            fastmap_1.1.1           fansi_1.0.4            
##  [82] digest_0.6.31           gridGraphics_0.5-1      R6_2.5.1               
##  [85] mime_0.12               colorspace_2.1-0        GO.db_3.17.0           
##  [88] scattermore_1.1         tensor_1.5              spatstat.data_3.0-1    
##  [91] RSQLite_2.3.1           utf8_1.2.3              tidyr_1.3.0            
##  [94] generics_0.1.3          data.table_1.14.8       graphlayouts_1.0.0     
##  [97] httr_1.4.6              htmlwidgets_1.6.2       scatterpie_0.2.0       
## [100] uwot_0.1.14             pkgconfig_2.0.3         gtable_0.3.3           
## [103] blob_1.2.4              lmtest_0.9-40           XVector_0.40.0         
## [106] shadowtext_0.1.2        htmltools_0.5.5         carData_3.0-5          
## [109] fgsea_1.26.0            scales_1.2.1            Biobase_2.60.0         
## [112] png_0.1-8               ggfun_0.0.9             rstudioapi_0.14        
## [115] reshape2_1.4.4          nlme_3.1-162            cachem_1.0.8           
## [118] zoo_1.8-12              KernSmooth_2.23-21      HDO.db_0.99.1          
## [121] parallel_4.3.0          miniUI_0.1.1.1          AnnotationDbi_1.62.1   
## [124] pillar_1.9.0            vctrs_0.6.2             RANN_2.6.1             
## [127] promises_1.2.0.1        car_3.1-2               xtable_1.8-4           
## [130] cluster_2.1.4           evaluate_0.21           cli_3.6.1              
## [133] compiler_4.3.0          rlang_1.1.1             crayon_1.5.2           
## [136] future.apply_1.11.0     ggsignif_0.6.4          labeling_0.4.2         
## [139] plyr_1.8.8              stringi_1.7.12          deldir_1.0-6           
## [142] BiocParallel_1.34.2     munsell_0.5.0           Biostrings_2.68.1      
## [145] lazyeval_0.2.2          spatstat.geom_3.2-1     GOSemSim_2.26.0        
## [148] Matrix_1.5-4            patchwork_1.1.2         bit64_4.0.5            
## [151] future_1.32.0           KEGGREST_1.40.0         shiny_1.7.4            
## [154] highr_0.10              ROCR_1.0-11             igraph_1.4.2           
## [157] broom_1.0.4             memoise_2.0.1           bslib_0.4.2            
## [160] ggtree_3.8.0            fastmatch_1.1-3         bit_4.0.5              
## [163] downloader_0.4          gson_0.1.0              ape_5.7-1